package com.zoe.onelink.plugin.check.model;

import com.zoe.onelink.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2022</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2022-09-19
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class PropertyCheckResult<T> {

    private String propKey;
    private T propValue;
    private Level level;
    private String message;

    @Getter
    @AllArgsConstructor
    public enum Level {

        /**
         * 调试专用
         */
        DEBUG(10, "调试"),
        /**
         * 普通级别，自动忽略
         */
        NORMAL(20, "正常"),
        /**
         * 存在风险级别只会打印警告日志
         */
        DANGER(30, "存在风险"),
        /**
         * 严重级别会在启动时直接抛出异常
         */
        SEVERITY(40, "严重");

        private final int val;
        private final String desc;
    }

    public String getFormattedMessage() {
        return StrUtil.format("[PropertyChecker] [{}] {}", this.getLevel().getDesc(), this.getMessage());
    }


}
